<template>
  <div>
    <div style="margin: 0.2rem 0.6rem">{{ title }}</div>

    <!-- 自定义collection -->
    <div style="margin: 0.3rem 0.6rem">
      <div class="collection">
        <div
          class="coll-item"
          v-for="(item, index) in itemList"
          :key="item.id"
          :style="{
            background: '#c3c3c5',
          }"
          @click="itemClick(index)"
        >
          <i :style="{ color: item.select ? '#F599A0' : 'black' }">
            {{ item.title }}
          </i>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  title: {
    type: String,
  },
  itemList: {
    type: Array,
    default: [],
  },
});

const itemClick = (index) => {
  console.log(index);
};
</script>

<style lang="scss" scoped>
.collection {
  display: flex;
  flex-flow: row wrap; //主轴方向和换行属性复合写法:
  justify-content: flex-start;
  text-align: center;
  align-items: center;

  .coll-item {
    margin: 0.5rem;
    width: 20%;
    height: 30px;
    background-color: #f7f7f7;

    i {
      font-size: 12px;
      line-height: 30px;
    }
  }
}
</style>
